package com.ycjy.szteacher.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ycjy.szteacher.entity.Student;
import com.ycjy.szteacher.entity.Studentresult;
import com.ycjy.szteacher.mapper.StudentresultMapper;
import com.ycjy.szteacher.util.PageUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author 刘洋
 * @since 2020-10-19
 */
@SuppressWarnings("ALL")
@RestController
@RequestMapping("/studentresult")
public class StudentresultController {

    @Autowired
    private StudentresultMapper studentresultMapper;

    @RequestMapping(value = "/selectAllStudentResult")
    public PageUtil<Studentresult> selectAllStudentResult(String whichLesson, String studentNo) {
        Studentresult studentresult = new Studentresult();
        if (studentNo == null || studentNo.equals("")) {
            studentresult.setStudentNo(null);
        } else {
            studentresult.setStudentNo(Integer.parseInt(studentNo));
        }
        if (whichLesson == null || whichLesson.equals("")) {
            studentresult.setWhichLesson(null);
        } else {
            studentresult.setWhichLesson(whichLesson);
        }
        QueryWrapper<Studentresult> wrapper = new QueryWrapper<>(studentresult);
        Integer integer = studentresultMapper.selectCount(wrapper);
        List<Studentresult> studentresults = studentresultMapper.selectList(wrapper);
        long count = (long) integer;
        PageUtil<Studentresult> pageUtil = new PageUtil();
        pageUtil.setData(studentresults);
        pageUtil.setCount(count);
        return pageUtil;

    }

}

